Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/options: add flag to list a command's options #7839

Merged
merged 1 commit into from
Jun 29, 2020

Conversation

EricFromCanada
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Add a flag to brew options for listing a command's options and descriptions. This will be useful later for keeping shell completion files up to date.

Sample output:

$ brew options --command cleanup --compact
--debug --dry-run --prune --prune-prefix --verbose -s

$ brew options --command cleanup
--debug
	Display any debugging information.
--dry-run
	Show what would be removed, but do not actually remove anything.
--prune
	Remove all cache files older than specified <days>.
--prune-prefix
	Only prune the symlinks and directories from the prefix and remove no other files.
--verbose
	Make some output more verbose.
-s
	Scrub the cache, including downloads for even the latest versions. Note downloads for any installed formulae or casks will still not be deleted. If you want to delete those too: `rm -rf "$(brew --cache)"`

$ brew options --command update
--debug
	Display a trace of all shell commands as they are executed.
--force
	Always do a slower, full update check (even if unnecessary).
--help
	Show this message.
--merge
	Use `git merge` to apply updates (rather than `git rebase`).
--verbose
	Print the directories checked and `git` operations performed.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far!

Library/Homebrew/cmd/options.rb Outdated Show resolved Hide resolved
Library/Homebrew/cmd/options.rb Outdated Show resolved Hide resolved
Library/Homebrew/cmd/options.rb Show resolved Hide resolved
Library/Homebrew/cmd/options.rb Outdated Show resolved Hide resolved
path = Commands.path(args.command)
odie "Unknown command: #{args.command}" unless path
cmd_options = if cmd_parser = CLI::Parser.from_cmd_path(path)
cmd_parser.processed_options.map do |short, long, _, desc|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much nicer 😍

@MikeMcQuaid MikeMcQuaid merged commit d5306b8 into Homebrew:master Jun 29, 2020
@MikeMcQuaid
Copy link
Member

Thanks again @EricFromCanada!

@EricFromCanada EricFromCanada deleted the list-command-options branch June 29, 2020 13:51
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 27, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants